#ifndef ASSIMP_BYPASS_LOG
#define ASSIMP_BYPASS_LOG

#include <string.h>

#include <assimp/LogStream.h>
#include <assimp/Logger.h>

#include "../Util/Log.h"

class AssimpBypassLog : public Assimp::LogStream {
public:
	AssimpBypassLog(Log *log, Assimp::Logger::ErrorSeverity severity) {
		this->errLog = log;
		this->severity = severity;
	}

	virtual ~AssimpBypassLog() {
	}

	void write(const char* message)	{
		std::string s = message;
		std::string logMessage = s.substr(7,s.find_last_of('\n')-2); //remove logseverity from defaultlogger-message
		if(severity == Assimp::Logger::DEBUGGING) {
			errLog->LogDebug(logMessage);
		} else if(severity == Assimp::Logger::INFO)	{
			errLog->LogInfo(logMessage);
		} else if(severity == Assimp::Logger::WARN) {
			errLog->LogWarn(logMessage);
		} else if(severity == Assimp::Logger::ERR) {
			errLog->LogError(logMessage);
		}
	}

private:
	Assimp::Logger::ErrorSeverity severity;
	Log *errLog;
};

#endif //ASSIMP_BYPASS_LOG
